import { ImageResponse } from 'next/og'; import { Fallback, Wallpaper } from '@/components/brand/og'; import { fmtScoreUnit } from '@/components/models/shared'; import { apiD1, safe } from '@/lib/api'; import { fmtInt } from '@/lib/format'; import { routes, SITE_NAME } from '@/lib/site'; export const runtime = 'nodejs'; export const alt = `Benchmark leaderboard on ${SITE_NAME}`; export const size = { width: 1200, height: 630 }; export const contentType = 'image/png'; /** Benchmark OG: "Current recorded leader: X (score)" + results · models · metric · trust. */ export default async function BenchmarkOgImage({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const [d, list] = await Promise.all([safe(apiD1.benchmark(slug)), safe(apiD1.benchmarks())]); if (!d) return new ImageResponse(, { ...size }); const item = list?.items.find((b) => b.slug === d.slug || b.id === d.id) ?? null; const leader = item?.leader ?? d.leaderboard?.[0] ?? null; const counters: [string, string][] = []; counters.push(['Results', fmtInt(item?.result_count ?? d.result_count ?? 0)]); counters.push(['Models', fmtInt(item?.model_count ?? d.model_count ?? 0)]); if (d.metric ?? item?.metric) counters.push(['Metric', `${d.metric ?? item?.metric} ${(d.direction ?? item?.direction) === 'lower' ? '↓' : '↑'}`]); if (leader) counters.push(['Leader score', fmtScoreUnit(leader.score, leader.unit)]); const subtitle = leader ? `Current recorded leader: ${leader.model.name}${leader.model.organization ? ` (${leader.model.organization.name})` : ''} — ${leader.trust_label ?? leader.trust_level}` : 'No results recorded yet — sources being connected.'; return new ImageResponse(, { ...size }); }